<html xmlns:th="http://www.thymeleaf.org">
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>合同查看</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="../../../../static/easyui/themes/insdep/easyui.css" rel="stylesheet" type="text/css">
	<link href="../../../../static/easyui/themes/insdep/easyui_animation.css" rel="stylesheet" type="text/css">
	<link href="../../../../static/easyui/themes/insdep/easyui_plus.css" rel="stylesheet" type="text/css">
	<link href="../../../../static/easyui/themes/insdep/insdep_theme_default.css" rel="stylesheet" type="text/css">
	<link href="../../../../static/easyui/themes/insdep/icon.css" rel="stylesheet" type="text/css">
	<link href="../../../../static/easyui/themes/color.css" rel="stylesheet" type="text/css">

	<link href="../../../../static/ztree/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" >
	<link href="../../../../static/css/common.css" rel="stylesheet" type="text/css" >

	<script type="text/javascript" src="../../../../static/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="../../../../static/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../../static/easyui/themes/insdep/jquery.insdep-extend.min.js"></script>
	<script type="text/javascript" src="../../../../static/ztree/jquery.ztree.all.min.js"></script>
	<script type="text/javascript" src="../../../../static/easyui/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../../../../static/kindeditor/kindeditor-all-min.js"></script>

	<style type="text/css">
		td:nth-child(1){
			text-align:right;
		}
		td:nth-child(4){
			text-align:right;
		}
		table{
			margin:auto;
		}
		input[type="text"]{
			width:72.5%;
			height:30px;
			border:0.5px solid gray;
		}
		#select{
			width:72.5%;
			height:30px;
			border:0.5px solid gray;
		}
		td:only-child{
			text-align:center;

		}
	</style>
</head>

<body>
<div id="div1">
	<form  method="post" id="form">
		<table>
			<tr>
				<td>合同编号：</td>
				<td>
					<input type="hidden" name="contractVO.contractid" th:value="${contractVO.id }">
					<input type="text" name="number" th:value="${contractVO.number }" id="contractNumber" >
				</td>
				<td></td>
				<td>签约时间：</td>
				<td>
					<input class="easyui-datetimebox" name="dueTime" th:value="${contractVO.dueTime }">
				</td>
			</tr>
			<tr>
				<td>来源商机：(单击选择)</td>
				<td>
					<select id="select" name="businessId">
						<option th:value="${busin.id}" th:each="busin : ${tbCrmBusinesses}"  th:text="${busin.name}">请选择商机</option>
					</select>
				</td>
				<!--    				<td><a href="manage/business/BusinessAction_edit.action" style="color:blue;">新建商机</a></td>-->
				<td>联系人：</td>
				<td>
					<input type="text" name="csname" th:value="${contractVO.tbCrmContacts.csname}" id="connectionName" >
				</td>
			</tr>
			<tr>
				<td>来源客户：</td>
				<td><input type="text" name="name" id="businessCustomerName" th:value="${contractVO.tbCrmCustomer.name }"></td>
				<td></td>
				<td></td>
				<td></td>
			</tr>
			<tr>
				<td>负责人：<input type="hidden" name="username" id="ownerUserId"></td>
				<td><input type="text" th:value="${contractVO.tbSystemUser.username}" id="ownerUser"></td>
				<td></td>
				<td>合同金额：</td>
				<td>
					<input name="price" th:value="${contractVO.price }" type="text">
				</td>
			</tr>
			<tr>
				<td class="text-title">合同生效日期：</td>
				<td class="text-content">
					<input name="startDate" th:value="${contractVO.startDate }" class="easyui-datetimebox">
				</td>
				<td></td>
				<td>合同到期时间：</td>
				<td>
					<input name="endDate" th:value="${contractVO.endDate }"class="easyui-datetimebox">
				</td>
			</tr>
			<tr>
				<td>状态：</td>
				<td><input type="text" name="status" th:value="${contractVO.status}"></td>
				<td></td>
				<td></td>
				<td></td>
			</tr>
			<tr>
				<td>条件和条款：</td>
				<td colspan="4"><textarea rows="8" cols="100%" name="content" id="wysiwyg" th:text="${contractVO.content }"></textarea></td>
			</tr>
			<tr>
				<td>合同描述：</td>
				<td colspan="4"><textarea rows="4" cols="100%" name="description" th:text="${contractVO.description }"></textarea></td>
			</tr>
			<tr>
				<td colspan="5">
					<a href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton button-primary">保存</a>
					<a href="javascript:void(0);" id="resetBtn" class="easyui-linkbutton button-return">重置</a>
				</td>
			</tr>
		</table>
	</form>
</div>
</body>
<script type="text/javascript">
	$(function() {
		document.getElementById("businessCustomerName").style.backgroundColor = "#FFF8DC";
		document.getElementById("ownerUser").style.backgroundColor = "#FFF8DC";
		document.getElementById("connectionName").style.backgroundColor = "#FFF8DC";
		document.getElementById("contractNumber").style.backgroundColor = "#FFF8DC";
		var alerNumber=document.getElementById('contractNumber').value;
		if(!alerNumber){
			document.getElementById('contractNumber').value=new Date().getTime();
		}
		//导入编辑器
		KindEditor.ready(function(K) {
			//在编辑器初始化成功之后赋值editor变量
			window.editor = K.create("#wysiwyg",{
				minWidth : '300px',
				items:[
					'source', '|', 'code', 'cut', 'copy', 'paste',
					'plainpaste', 'wordpaste', '|', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
					'quickformat', 'selectall', '|',
					'formatblock', 'fontname', 'fontsize', '|', 'forecolor',  'bold',
					'underline', '|', 'image', 'multiimage',
					'flash', 'media','hr', 'emoticons', 'baidumap', 'pagebreak',
					'link'
				]
			});
		});


		document.getElementById("select").onchange=function (){
			$.post(
					"manage/position/ContractAction_findAll.action",
					function(data){
						var selectValue=$("#select").val();
						if(data){
							$.each(data.data,function(index,obj){
								if(selectValue==obj.id){
									document.getElementById('connectionName').value=obj.contactsName;
									document.getElementById('businessCustomerName').value=obj.customerName;
									document.getElementById('ownerUser').value=obj.ownerName;
									document.getElementById('ownerUserId').value=obj.ownerId;
									document.getElementById('contractNumber').readOnly=true;
									document.getElementById('connectionName').readOnly=true;
									document.getElementById('ownerUser').readOnly=true;
									document.getElementById('businessCustomerName').readOnly=true;
									document.getElementById("ownerUser").style.backgroundColor = "#D3D3D3";
									document.getElementById("connectionName").style.backgroundColor = "#D3D3D3";
									document.getElementById("businessCustomerName").style.backgroundColor = "#D3D3D3";

								}

							})
						}
					},"json"
			);

		};

		$.post(
				"manage/position/ContractAction_findAll.action",
				function(data){
					if(data){
						var businessId = "${contractVO.businessid}";
						$.each(data.data,function(index,obj){
							var option = $("<option"+" "+ "value="+obj.id+">"+obj.name+"</option>");
							if(businessId && businessId == obj.id){
								option.attr("selected",true);
							}
							$("#select").append(option);
						})
					}
				},"json"
		);


		//重置按钮
		$("#resetBtn").on("click",function(event){
			$("#form").form("reset");
		});
		//保存按钮
		$("#saveBtn").on("click", function(event) {
			editor.sync();
			$("#form").form("submit", {
				url : "editContract",
				onSubmit : function() {
					//对表单进行数据校验,如果未通过校验，返回false，阻止表单提交
					return $(this).form("validate");

				},
				success : function(data) {
					data = eval("("+data+")");
					if(data.success){
						$.messager.alert("提示",data.message,"info",function () {
							parent.closeTopWindow();
						})
					}else{
						$.messager.alert("警告",data.message,"info");
					}
				}
			});
		});

	});
</script>
</html>
